package appconfig

import (
	"github.com/spf13/viper"
	"log"
)

type AppConfig struct {
	Mysql
}
type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

var Appconf AppConfig

func Init() {
	var err error
	viper.SetConfigFile("appconfig/dev.yaml")
	if err = viper.ReadInConfig(); err != nil {
		log.Println("读取配置文件失败")
	}
	if err = viper.Unmarshal(&Appconf); err != nil {
		log.Println("解析配置文件失败")
	}
	log.Println("动态配置数据文件成功")
}
